public class Solution171 {
    public int titleToNumber(String columnTitle) {
        int ans=0;
        for (char c : columnTitle.toCharArray()) {
            ans=ans*26+c-'A'+1;
        }
        return ans;
    }

    public static void main(String[] args) {
        System.out.println(new Solution171().titleToNumber("AB"));
    }
}
